#define _CRT_SECURE_NO_WARNINGS 1


#include<stdbool.h>
struct ListNode {
	int val;
	struct ListNode* next;
};
bool hasCycle(struct ListNode* head)
{
	if (!head)
		return false;
	struct ListNode* slow = head, * fast = head;

	while (slow && fast)
	{
		if (fast->next)
		{
			fast = fast->next->next;
			slow = slow->next;
			if (slow == fast)
				return true;
		}
		else
			return false;

	}
	return false;

}